#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
    pid_t now=fork();
	if(now==0)
	{
	    pid_t id=getpid();
	    pid_t ppid=getppid();
		int cnt=3;
	    while(cnt)
	    {   
	        printf("this is child progress,cnt:%d,pid:%d,ppid:%d\n",cnt,id,ppid);
	        sleep(1);
			cnt--;
		}
		exit(6);
	}
	//sleep(5);
	//pid_t cid=wait(NULL);
	int stau = 0;
	while(1)
	{
		pid_t cid=waitpid(now,&stau,WNOHANG);
		if(cid>0)
		{
			printf("wait success,cid:%d,stau:%d,exitcode:%d,exitsignal:%d\n",cid,stau,stau>>8,stau&0x7f);
		break;
		}
		printf("is waiting!\n");
	}
    return 0;

}

